/* Exercice 5.39
   ejer_5_39.c */
#include <stdio.h>

int gcd(int x, int y);

/* function main begins program execution */
int main(void)
{
    int a, b;

    printf("Enter two numbers: ");
    scanf("%d%d", &a, &b);

    printf("The gcd between %d and %d is %d\n", a, b, gcd(a, b));
    return 0;
} /* end function main */

/* This is a recursive function that returns the gcd between two numbers */
int gcd(int x, int y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}
